<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page import="net.luvina.manageuser.entities.*"%>
<%@page import="net.luvina.manageuser.utils.*"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<title>ユーザ管理</title>
</head>
<body>

<jsp:include page="header.jsp" />

<!-- Begin vung dieu kien tim kiem -->
<form action="ListUser.do" method="post" name="mainform">
<!-- Begin Tag hidden -->
<input type="hidden" name="page" value="1" />
<!-- End Tag hidden -->
<table class="tbl_input" border="0" width="90%" cellpadding="0"
	cellspacing="0">
	<tr>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td>会員名称で会員を検索します。検索条件無しの場合は全て表示されます。</td>
	</tr>
	<tr>
		<td width="100%">
		<table class="tbl_input" cellpadding="4" cellspacing="0">
			<tr>
				<td class="lbl_left">氏名:</td>
				<td align="left"><input class="txBox" type="text"
					name="fullName" value="${fullName}" size="20"
					onfocus="this.style.borderColor='#0066ff';"
					onblur="this.style.borderColor='#aaaaaa';" /></td>
			</tr>
			<tr>
				<td class="lbl_left">グループ:</td>
				<td align="left" width="80px">
					<select name="groupId">
						<option value="0">全て</option>
						<c:forEach var="group" items="${listGroup}">
							<c:choose>
								<c:when test="${groupId == group.groupId}">
									<option value="${group.groupId}" selected="selected">${group.groupName}</option>
								</c:when>
								<c:otherwise>
									<option value="${group.groupId}">${group.groupName}</option>
								</c:otherwise>
							</c:choose>
						</c:forEach>
					</select>
				</td>
				<td align="left">
					<input class="btn" type="submit" value="検索" />
					<input name="btn_add" onclick="location.href='AddUserInput.do'" class="btn" type="button" value="新規追加" />
				</td>
			</tr>
		</table>
		</td>
	</tr>
</table>
</form>
<!-- End vung dieu kien tim kiem -->


<!-- Begin vung hien thi danh sach user -->
<c:choose>
	<c:when test="${not empty message}">
		<table class="tbl_list" border="1" cellpadding="4" cellspacing="0"
			width="100%">
			<tr>
				<td class="errMsg">${message}</td>
			</tr>
		</table>
	</c:when>
	<c:otherwise>
		<table class="tbl_list" border="1" cellpadding="4" cellspacing="0"
			width="80%">
			<tr class="tr2">
				<th align="center" width="20px">ID</th>
				<th align="left">氏名 <c:choose>
					<c:when test="${sortByFullName eq 'ASC'}">
						<a
							href="ListUser.do?page=1&sortType=full_name&sortValue=DESC">▲▽</a>
					</c:when>
					<c:otherwise>
						<a href="ListUser.do?page=1&sortType=full_name&sortValue=ASC">△▼</a>
					</c:otherwise>
				</c:choose></th>
				<th align="left">生年月日</th>
				<th align="left">グループ</th>
				<th align="left">メールアドレス</th>
				<th align="left" width="70px">電話番号</th>
				<th align="left">日本語能力 <c:choose>
					<c:when test="${sortByCodeLevel eq 'ASC'}">
						<a
							href="ListUser.do?page=1&sortType=code_level&sortValue=DESC">△▼</a>
					</c:when>
					<c:otherwise>
						<a
							href="ListUser.do?page=1&sortType=code_level&sortValue=ASC">▲▽</a>
					</c:otherwise>
				</c:choose></th>
				<th align="left">失効日 <c:choose>
					<c:when test="${sortByEndDate eq 'ASC'}">
						<a href="ListUser.do?page=1&sortType=end_date&sortValue=DESC">▲▽</a>
					</c:when>
					<c:otherwise>
						<a href="ListUser.do?page=1&sortType=end_date&sortValue=ASC">△▼</a>
					</c:otherwise>
				</c:choose></th>
				<th align="left">点数</th>
			</tr>

			<c:forEach var="user" items="${listUser}">
				<tr>
					<td align="right"><a href="jsp/ADM005.jsp">${user.userId}</a></td>
					<td align="left">${user.fullName}</td>
					<td align="center">${user.birthday}</td>
					<td align="left">${user.groupName}</td>
					<td align="left">${user.email}</td>
					<td align="left">${user.tel}</td>
					<td align="left">${user.nameLevel}</td>
					<td align="center">${user.endDate}</td>
					<td align="right">
					<c:choose>
						<c:when test="${user.total != 0}">
							${user.total}
						</c:when>
						<c:otherwise>
						</c:otherwise>
					</c:choose>
					</td>
				</tr>
			</c:forEach>
		</table>
		<!-- End vung hien thi danh sach user -->

		<!-- Begin vung paging -->
		<table>
			<tr>
				<c:if test="${currentSection != 1}">
					<td class="lbl_paging"><a
						href="ListUser.do?page=${minPage - 3}">&lt;&lt;</a></td>
				</c:if>

				<c:forEach begin="${minPage}" end="${maxPage}" var="i">
					<c:if test="${currentPage <= maxPage }">
						<c:choose>
							<c:when test="${currentPage eq i}">
								<td class="lbl_paging">${i}</td>
							</c:when>
							<c:otherwise>
								<td class="lbl_paging"><a href="ListUser.do?page=${i}">${i}</a></td>
							</c:otherwise>
						</c:choose>
					</c:if>
				</c:forEach>

				<c:if test="${currentSection lt totalSection }">
					<td class="lbl_paging"><a
						href="ListUser.do?page=${maxPage + 1}">&gt;&gt;</a></td>
				</c:if>
			</tr>
		</table>
		<!-- End vung paging -->
	</c:otherwise>
</c:choose>

<jsp:include page="footer.jsp" />

</body>
</html>